package com.wyx.suanfa;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class isBalanced {
    //给定一个二叉树，判断它是否是平衡二叉树
    public static void main(String[] args) {

    }
}

/*
* class Solution {
    public boolean isBalanced(TreeNode root) {
        return getHeight(root) != -1;

    }
    public int getHeight(TreeNode root){
        if(root == null){
            return 0;
        }

        int leftHeight = getHeight(root.left);
        if(leftHeight == -1){
            return -1;
        }

        int rightHeight = getHeight(root.right);
        if(rightHeight == -1){
            return -1;
        }

        if(Math.abs(leftHeight - rightHeight) > 1){
            return -1;
        }

        return Math.max(leftHeight,rightHeight) + 1;
    }
}*/